<?php

namespace App\Service;

use App\Models\MemberFlow;
use App\User;

class UserFlowService
{
    /**
     * 添加用户流水
     * @param User $user
     * @param $type   1 支出 2 收入
     * @param $desc
     * @param $amount
     * @return mixed
     */
    public function create(User $user, $type, $desc, $amount)
    {
        return MemberFlow::create([
            'member_id'         => $user->id,
            'type'              => $type,
            'desc'              => $desc,
            'amount_balance'    => $user->gourd_coin,
            'amount'            => $amount
        ]);
    }
}
